<?php get_header();?>
<?php get_template_part('left','menu');?>
<section>
<div class="container">
<div class="findBox" >		
            <div class="love_title">
                <div class="fontTitle" style="padding-left:10px; padding-top:20px"><a href="<?php echo get_post_type_archive_link( 'detail' ); ?>" class="findTitleWord">发现频道</a></div>
            </div>
			<div class="con_title"> <span class="conName"><?php the_title();?><span class="red">&nbsp;&nbsp;&nbsp;<?php echo get_post_meta($post->ID,"_red_title",true);?></span></span>
				<div class="conTime"><?php the_time('y-m-d');?></div>
				<div class="clear"></div>
			</div>
			<?php if( have_posts() ) : the_post();?>
			<div class="findPicBox">
				<div class="findPic"><a href="<?php echo home_url('/');?>go/<?php echo $post->ID?>" rel="nofollow" class="border_radius_3" target="_blank">
                <div style="height:20px"></div>
				<?php
				if( has_post_thumbnail() ){
					echo get_the_post_thumbnail( $post->ID, array(300, 300), array('alt'=>$post->post_title) );
				}else{
					echo '<img src="'.get_post_img( '', 300, 300 ).'" alt="'.$post->post_title .'"  width="300" height="300"/>';
				}
				?>
				</a>
				</div>
				<div class="findRight">
					<div class="findWidth"><div class="perBoxfl">商家分类：<?php $terms = get_the_terms( $post->ID, 'shop' );
			if ( $terms && ! is_wp_error( $terms ) ) : 
				$draught_links = array();
				foreach ( $terms as $term ) {
					$draught_links[] = $term->name;
					}
				$on_draught = join( ", ", $draught_links );
				echo $on_draught;
			endif; ?></div>
					<div class="perBoxsc" title="JamesJing">推荐人：<?php if(get_post_meta($post->ID,'_post_author',true)){ echo get_post_meta($post->ID,'_post_author',true); }else{ the_author();} ?></div><div class="clear"></div>
					<div class="nrBox">
					<?php the_content();?>
					</div>
					<div class="likeleft">
                    
                    <?php	
                            if( $user_ID != '' && $user_ID > 0 ) { 
                            $results = $wpdb->get_results("SELECT post FROM wp_userpost_fav WHERE user = $user_ID");
                            $user_faves_arr=array();
                            foreach($results as $result)
                            {                                  
                                array_push($user_faves_arr,$result->post);
                            }	
                            if( !in_array( $post->ID, $user_faves_arr ) ) {
                                    ?>     						
                                        <span class="add_fav"><a href="javascript:void(0);" id="<?php echo the_ID(); ?>" title="收藏本文" class="add_to_fav">  收藏  </a></span> 
                                    
                                        <?php } else { ?>
                                     <span class="add_fav"><a href="javascript:void(0);" id="<?php echo the_ID(); ?>" title="收藏本文" class="add_to_fav">收藏</a></span> 							
                                        <?php } ?> 
                        
                        <?php } else {?>						
                                        <span class="add_fav"><a href="javascript:void(0);" id="<?php echo the_ID(); ?>" title="收藏本文" class="add_to_fav_unlogin">收藏</a></span> 
                               
                        <?php }	?>	
        
                    
                    
                    
                    
					</div>
					<div class="likeNum"><?php echo get_post_fav_count($post->ID);?></div>					
										<div class="linkRight" style="margin-right:10px"> <a href="<?php echo home_url('/');?>go/<?php echo $post->ID?>" rel="nofollow" class="border_radius_3"  style="width:65px" target="_blank">直达链接</a></div>
										<div class="clear"></div></div>
				</div>
				
				<div class="clear"></div>
				<?php endif;?>
			</div>
<div id="comments" style="padding-left:10px">
<?php comments_template(); ?>
</div>
<div class="loveguessTitle" style="margin-left:10px; margin-top:30px;">你可能还喜欢</div>
 <?php 
 $args=array(
	'post_type'=>'detail',
	'orderby'=>'rand',
	'showposts'=>25
);
query_posts($args)?>
<div class="masonryWrap mar" id='love_content' style="width:710px">
<?php if( have_posts() ) : while( have_posts() ) : the_post();?>
<div class="masonryBrick mBalso" >
			<div class="blBox"  > 
				<div class="blPic" id="blPic_<?php echo $post->ID;?>">
				<a href="<?php echo home_url('/');?>go/<?php echo $post->ID?>" rel="nofollow" class="border_radius_3" target="_blank">
				<?php
				if( has_post_thumbnail() ){
					echo get_the_post_thumbnail( $post->ID, array(190, 190), array('alt'=>$post->post_title) );
				}else{
					echo '<img src="'.get_post_img( '', 190, 190 ).'" alt="'.$post->post_title .'" width="190" height="190"/>';
				}
				?>
				</a>
				<div class="blStore">
				<?php $terms = get_the_terms( $post->ID, 'shop' );
			if ( $terms && ! is_wp_error( $terms ) ) : 
				$draught_links = array();
				foreach ( $terms as $term ) {
					$draught_links[] = $term->name;
					}
				$on_draught = join( ", ", $draught_links );
				echo $on_draught;
			endif; ?>
				</div>
				</div>
				<a class="mB10 blTitle" href="<?php the_permalink();?>" target="_blank"><?php the_title();?><span class="red">&nbsp;&nbsp;&nbsp;<?php echo get_post_meta($post->ID,"_red_title",true);?></span></a>
				<div class="blInfo mB10">
				<strong><?php if(get_post_meta($post->ID,'_post_author',true)){ echo get_post_meta($post->ID,'_post_author',true); }else{ the_author();} ?>：</strong><?php echo mb_substr($post->post_title,0,50,'UTF-8');?><div class="blTime"><?php the_time('m-d');?></div>
				</div>	
				<div class="blBot">
					<div class="blLike">
					<a class="love_collect" href="javascript:void(0);" id="<?php echo the_ID(); ?>" title="收藏本文" class="add_to_fav"><?php echo get_post_fav_count($post->ID);?></a>
					<div class="blLikeTip">
					<div class="blLikeTipInner" id='textcollect_<?php echo the_ID(); ?>'>收藏</div><div class="blLikeTipBot"></div></div>
					</div>
					<div class="blComment"><?php comments_popup_link( '0', '1', '%'); ?></div>
					<div class="blzd"><a href="<?php echo home_url('/');?>go/<?php echo $post->ID?>" rel="nofollow" class="border_radius_3" target="_blank">直 达 链 接</a></div>
					<div class="clear"></div>
				</div>
			</div>
			</div>
	<?php endwhile;endif;?>
	</div>
</div>
<?php get_sidebar();?>
<div class="clear"></div>
</div>
</section>
<?php get_footer();?>